package com.huikaka.mapper;

import com.huikaka.entity.AwardTable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface AwardTableMapper {

    @Select("select (select sum(award_mount) as 'all_award_mount' from award where invite_code=#{inviteCode}) as 'all_award_mount',\n" +
            "(select sum(award_mount) as 'today_award_mount' from award where invite_code=#{inviteCode} and  to_days(award_date) = to_days(now())) as 'today_award_mount',\n" +
            "(select (select sum(award_mount) from award where award.invite_code=#{inviteCode})- (select sum(withdraw_mount) from withdraw where withdraw.invite_code =#{inviteCode})as 'now_banlance')  as 'now_banlance',\n" +
            "(select sum(withdraw_mount) as 'all_withdraw_mount' from withdraw where invite_code = #{inviteCode}) as 'all_withdraw_mount'")
    public AwardTable getAwardTable(String inviteCode);
}
